{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "使用GBDT解决分类问题\n",
    "\n",
    "数据集：白酒数据，共有13个特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.preprocessing import LabelEncoder\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.tree import DecisionTreeClassifier\n",
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "from sklearn.metrics import accuracy_score"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Class labels [1 2 3]\n"
     ]
    }
   ],
   "source": [
    "cwd = '/home/xijian/pycharm_projects/Magic-NLPer/MachineLearning/'\n",
    "data_dir = cwd+'RandomForest随机森林/data/'\n",
    "\n",
    "# Wine dataset and rank the 13 features by their respective importance measures\n",
    "df_wine = pd.read_csv(data_dir+'wine.data',\n",
    "                      header=None,\n",
    "                      names=['Class label', 'Alcohol', 'Malic acid', 'Ash', 'Alcalinity of ash', 'Magnesium',\n",
    "                               'Total phenols', 'Flavanoids', 'Nonflavanoid phenols', 'Proanthocyanins', 'Color intensity',\n",
    "                               'Hue', 'OD280/OD315 of diluted wines', 'Proline'])\n",
    "print('Class labels', np.unique(df_wine['Class label'])) # 一共有3个类\n",
    "\n",
    "df_wine = df_wine[df_wine['Class label']!=1] # 去掉一个类\n",
    "\n",
    "y = df_wine['Class label'].values\n",
    "X = df_wine[['Alcohol', 'OD280/OD315 of diluted wines']].values"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Class labels [0 1]\n",
      "numbers of features: 2\n"
     ]
    },
    {
     "data": {
      "text/plain": "(95, 2)"
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "le = LabelEncoder()\n",
    "y = le.fit_transform(y)\n",
    "\n",
    "print('Class labels', np.unique(y))\n",
    "print('numbers of features:', X.shape[1])\n",
    "\n",
    "# 划分训练集测试集\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=1, stratify=y)\n",
    "X_train.shape\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Decision tree train/test accuracies 0.916/0.875\n"
     ]
    }
   ],
   "source": [
    "# 先使用决策树做分类，作为GBDT的对比参照\n",
    "tree = DecisionTreeClassifier(criterion='entropy',\n",
    "                              random_state=1,\n",
    "                              max_depth=1)\n",
    "tree = tree.fit(X_train, y_train)\n",
    "y_train_pred = tree.predict(X_train)\n",
    "y_test_pred = tree.predict(X_test)\n",
    "tree_train = accuracy_score(y_train, y_train_pred)\n",
    "tree_test = accuracy_score(y_test, y_test_pred)\n",
    "print('Decision tree train/test accuracies %.3f/%.3f' % (tree_train, tree_test))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "GBDT train/test accuracies 1.000/0.917\n"
     ]
    }
   ],
   "source": [
    "# 使用GBDT分类\n",
    "gbm = GradientBoostingClassifier(n_estimators=500,\n",
    "                                 learning_rate=0.1,\n",
    "                                 random_state=1,\n",
    "                                 criterion='friedman_mse',\n",
    "                                 max_depth=1,\n",
    "                                 loss='deviance')\n",
    "# 对于分类问题，损失函数默认是\"deviance\"对数似然损失函数，如果是\"exponential\"则表示指数损失函数\n",
    "gbm = gbm.fit(X_train, y_train)\n",
    "y_train_pred = gbm.predict(X_train)\n",
    "y_test_pred = gbm.predict(X_test)\n",
    "gbm_train = accuracy_score(y_train, y_train_pred)\n",
    "gbm_test = accuracy_score(y_test, y_test_pred)\n",
    "print('GBDT train/test accuracies %.3f/%.3f' % (gbm_train, gbm_test))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 576x216 with 2 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAesAAADkCAYAAAC40gzAAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA0aklEQVR4nO3dd5wkVbn/8c8zszubc2IzklF+BH8EAwrXvQQFxQwKigteRDBwL8EL/Ihe7uUSBJFdFdwFZZcVFRRYMkjYFQRBQNIicQObc2DDzPTz+6OqZ2t6OlT3dKie+b5fr37tdFdV1+nZefo559Spc8zdERERkeRqqHUBREREJD8laxERkYRTshYREUk4JWsREZGEU7IWERFJOCVrERGRhFOy7kbM7D4zOzHGfhvNbKdqlElERApTsk4YM3vXzDab2QYzW2tmT5rZqWbW6f8rd/+0u/86xn793f3tzp4vKqwApB+p8DOmnx9fznOJdBdmdpyZPW1mm8xsefjzaRa42cy2hTG2wcyeM7NDIsd+y8xaI3H4jpndZGa7hds/Edm2ycw8I44n1O6Tdz9K1sn0WXcfAEwELgd+BEyrbZE6J6wA9Hf3/sACgs+Yfm1mej8z61G7UorUDzM7E/gpcCWwAzAKOBX4ONAU7nZFGHMDgZ8Dd5hZY+Rtngq3DwL+FdgMPGdme7n7nEjMfijcf3AkbhdU+jPKdkrWCebu69z9LuBY4EQz2wvAzHq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PUVwkSSbZu5LRjgBbgmRzbe5DnOmwBDnS4Xh5aTJBoAAivq48n6GkoZAkwJOyiTpsQs0ybgL6R5ztkbM9cL3gh8Li7D448+rv7dwnGKLSE5Y5bjscJKjBN7v5e+PxEggGJL8T8DJnluyyjfH3DMQu4+63ufjDB79oJBk9KnVKyFgHcfR1BK/JnZnakmfU0sx0Jrv0uIugSbiccmLQnwfXXHYCfhK+PBf4MXO/uv8hyur8B3zSzQWHr9jRgcTjwaxNBS/tSM+tnZh8nSKrp80evV0Mw8nsQMM3MdjCz3mb2NeB84GzPsmC9BbeGHU/Qwv9fd18VDm76jpkNscCBwOlEKilm1hQObjKgZ3iuhnDbp81sVPjzHsAFBNfEs/kdcJSZTQo//5kEFaUnc+zfxt3nA88Cl4TlOZigohTHC8AnLbgXexBwbsb2ZcBOkeezgd3M7Bvh30NPMzvAzPYMK0t3ABebWd/wOnaha+ePE1xHfiJ8/lj4fG4pt5oBNwKnmtlB4f9ZPzM7yswGWHCv+qfMrBfBdfXNBAMGpV65ux566BE+gJOBlwm+3JYRDNoZEtl+MdBM0F29ieD681RgbGSfiwhaMhujj8j2YcBMYDmwluDWqwMj24cCfwrffwHw9fB1I+gSHZlR5gkEFYbV4TF/A47J2MfDbRvD/R5Nv2+4vQG4P9y2kaBFfh5gkX0eC98n+jg03HZV+PvaRDB46lKgZ57f8xeAVwmuiT8OfCjjPN/Oc+xOBL0YGwkGgF0PzAi37RiWq0e29yKooKwF3gT+LWPfj4afew3BdWIIbnO7h6AlvYqgErZvuG0EQUJfT9A78WOCxJur3LuH5zsxfD6IoHX+o8g+hwKLIs/fBf414+9vRuT5keH/91qCXoffE4w52Dss04bw/3Q2Qfd4zWNMj9IeFv6Hi0jCha3d6939wII7i0iXom5wkfpyUeFdRKSrUctaREQk4dSyFhERSTglaxERkYRTshYREUk4JWsREZGEU7IWERFJOCVrERGRhPv/EpThBWFk47UAAAAASUVORK5CYII=\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制决策边界\n",
    "def plot_decision_regions(X, y, classifier_list, classifier_names):\n",
    "    x_min = X[:, 0].min() - 1\n",
    "    x_max = X[:, 0].max() + 1\n",
    "    y_min = X[:, 1].min() - 1\n",
    "    y_max = X[:, 1].max() + 1\n",
    "\n",
    "    xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1),\n",
    "    np.arange(y_min, y_max, 0.1))\n",
    "\n",
    "    f, axarr = plt.subplots(1, 2, sharex='col', sharey='row', figsize=(8, 3))\n",
    "\n",
    "    for idx, clf, tt in zip([0, 1],classifier_list,classifier_names):\n",
    "        clf.fit(X, y)\n",
    "        Z = clf.predict(np.c_[xx.ravel(), yy.ravel()])\n",
    "        Z = Z.reshape(xx.shape)\n",
    "        axarr[idx].contourf(xx, yy, Z, alpha=0.3)\n",
    "        axarr[idx].scatter(X[y==0, 0], X[y==0, 1], c='blue', marker='^')\n",
    "        axarr[idx].scatter(X[y==1, 0], X[y==1, 1], c='red', marker='o')\n",
    "        axarr[idx].set_title(tt)\n",
    "        axarr[0].set_ylabel('Alcohol', fontsize=12)\n",
    "\n",
    "    plt.text(10.2, -0.5, s='OD280/OD315 of diluted wines', ha='center', va='center', fontsize=12)\n",
    "    plt.show()\n",
    "\n",
    "plot_decision_regions(X_train, y_train, [tree, gbm], ['Decision Tree', 'GBDT'])\n"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AdaBoost train/test accuracies 1.000/0.917\n"
     ]
    }
   ],
   "source": [
    "# 使用AdaBoost+DecisionTree分类树 能基本实现GBDT分类问题\n",
    "from sklearn.ensemble import AdaBoostClassifier\n",
    "ada = AdaBoostClassifier(base_estimator=tree,\n",
    "                         n_estimators=500,\n",
    "                         learning_rate=0.1,\n",
    "                         random_state=1)\n",
    "ada = ada.fit(X_train, y_train)\n",
    "y_train_pred = ada.predict(X_train)\n",
    "y_test_pred = ada.predict(X_test)\n",
    "ada_train = accuracy_score(y_train, y_train_pred)\n",
    "ada_test = accuracy_score(y_test, y_test_pred)\n",
    "print('AdaBoost train/test accuracies %.3f/%.3f' % (ada_train, ada_test))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 576x216 with 2 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAesAAADkCAYAAAC40gzAAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAA2gUlEQVR4nO3deZwcVb3//9dntuz7RnZk32TxB6hf2TQXAQFRQbgKggFEFBfuBfQKCqJyxQVBIFHABBRCQEW2gEQIhJALgqgsKiBb9oTsK0lm6c/vj6qe1PT0Pr1Uz7yfj0c/Mt1VXXV6Mp/+nHPq1Dnm7oiIiEh81VW7ACIiIpKdkrWIiEjMKVmLiIjEnJK1iIhIzClZi4iIxJyStYiISMwpWfcgZvZHMzsrj/02m9kulSiTiBTOzG4zsx9UuxxSOUrWMWNmC8xsq5ltMrP1Zva0mZ1vZl3+v3L349z913ns19/d3+rq+aLCCkDykQg/Y/L56aU8l0gtM7O5ZrbOzHqV8HjbwljbYGbzzOy9pTh2lnOqMlFiStbxdKK7DwAmAlcD3wSmVbdIXRNWAPq7e39gEcFnTL42I7mfmTVUr5Qi1WVmOwOHAw58vISH/koYe0OBucDtJTy2VICSdYy5+wZ3fwA4DTjLzPYDMLNeZvZTM1tkZu+Y2S/NrE/yfWZ2kpm9YGYbzexNMzs2fH2umZ0b/rybmT0Z1rRXm9ndkfe7me0W/jzIzH5jZqvMbKGZfTvZyjezz5vZ/LAs68zsbTM7rpDPa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sMaAzPVRduO87MRoU/7wV8h+CaeDq/BY43s0nh57+IoKL0dIb927n7QuB54MqwPIcRVJTy8QJwhAX3Yg8CvpWy/R1gl8jzWcAeZva58O+h0cwOMbO9w8rSH4Dvmlnf8Dp2rmvnTxJcR54XPp8bPp9fzK1mwC3A+Wb2/vD/rJ+ZHW9mAyy4V/0jZtaL4Lr6VoIBg1Kr3F0PPfQIH8A5wD8IvtzeIRi0MySy/btAC0F39RaC689TgbGRfa4gaMlsjj4i24cBM4CVwHqCW68OjWwfCtwXHn8R8NnwdSPoEh2ZUuYJBBWGteF7/gKclLKPh9s2h/s9kTxuuL0OeCTctpmgRX4pYJF95obHiT6OCrf9NPx9bSEYPPU9oDHL7/mTwL8Irok/Ceybcp5zs7x3F4JejM0EA8BuBO4It+0clqsh3bEIKijrgTeAL6Ts+8Hwc68juE4MwW1uDxG0pNcQVMIODLeNIEjoGwl6J75PkHgzlXvP8Hxnhc8HEbTOvxnZ5yhgSeT5AuA/Uv7+7og8Pzb8/15P0OvwO4IxB/uHZdoU/p/OIuger3qM6VHcw8L/cBGJubC1e6O7H5pzZxHpVtQNLlJbrsi9i4h0N2pZi4iIxJxa1iIiIjGnZC0iIhJzStYiIiIxp2QtIiISc0rWIiIiMadkLSIiEnP/PzBIu3mAaTEYAAAAAElFTkSuQmCC\n"
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot_decision_regions(X_train, y_train, [tree, ada], ['Decision Tree', 'AdaBoost'])"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}